package 线程的状态;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: sfx
 * Date: 2022-11-21
 * Time: 12:24
 */

public class joinApply2 {
    public static int a = 0;
    public static void main(String[] args) throws InterruptedException {
        Thread t = new Thread(()->{
            try {
                Thread.sleep(2000);//等待2s
                a = 100;
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        });
        t.start();
        //如果线程结束了,这个join也会提前结束
        t.join(2500);
        System.out.println(a);
    }
}
